package com.example.helloandroid;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.Spinner;
import android.widget.TextView;
import android.widget.AdapterView.OnItemSelectedListener;

public class TestSpinControl extends Activity implements OnItemSelectedListener{

	TextView selection;
	private String itemList[] = {"second","first", "spinner"};
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.spincontro);
		Spinner spin = (Spinner) findViewById(R.id.Spinner01);
		spin.setOnItemSelectedListener(this);
		selection = (TextView) findViewById(R.id.SpinTextView01);		
		ArrayAdapter<String> aa = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_dropdown_item, itemList);
		
		aa.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
		spin.setAdapter(aa);
	}

	public void onItemSelected(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
		selection.setText(itemList[arg2]);
	}

	public void onNothingSelected(AdapterView<?> arg0) {
		selection.setText("");
	}

}
